Skip to content

Conversation

@keturn
Copy link

@keturn keturn commented May 3, 2025

An attempt to get it to build libpatchmatch.so at build time, so it can be distributed in wheels—or when wheels aren't available, have it build at install time instead of runtime.

Notes:

  • I haven't tested this with Windows, so I've left the Windows fallback code as it is.
  • package version number is specified both in __init__.py and meson.build

Kevin Turner added 2 commits May 2, 2025 21:26
build: use importlib to find library
    so it works in editable mode as supported by meson-python
@keturn keturn marked this pull request as ready for review May 3, 2025 19:37
@keturn
Copy link
Author

keturn commented May 3, 2025

now 90% less janky, ctypes loads the library in both editable and built installations.

@mauwii
Copy link
Owner

mauwii commented May 6, 2025

Hi, sorry, just saw your PR after I begun rising the required python version (I randomly installed invokeai today and saw that patchmatch wasnt working...).

I will take a look at it these days, sounds pretty nice!

@mauwii
Copy link
Owner

mauwii commented May 19, 2025

When I do a clean installation on my Mac, it is not building the lib and the python examples are failing.

@keturn
Copy link
Author

keturn commented May 19, 2025

On mac it didn't attempt to build during installation at all? Huh, didn't expect that.

If you explicitly do uv build, does it make a .whl in dist/?

@mauwii
Copy link
Owner

mauwii commented May 19, 2025

Yes, it throws 4 warnings, but succeeds in building the wheel


# Compile if we didn't find a platform-compatible version (and it's not compiled already)
if pypatchmatch_lib is None:
pypatchmatch_lib = "libpatchmatch.so"
Copy link
Owner

@mauwii mauwii Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I change line 161 to pypatchmatch_lib = "libpatchmatch.dylib", it seems to be working properly on my Mac

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a check to use than name when platform is darwin.

It's suspicious to me to have to hardcode these extensions here rather than using a more standardized interface that already knows these platform-specific conventions, but I didn't find one of those.

Copy link
Owner

@mauwii mauwii Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was playing around with Windows to see if I can get it working there as well, but I only have access to a VM which runs on ARM, which is why I think I am failing ...

What's nagging me about the dylib: When I build the main branch on my Mac, it is generating a libpatchmatch.so instead. So maybe there is a attribute in meson.build to change that behaviour 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants